refactor: migrate to Session API with improved caching and cross-platform support#89
Merged
branchseer merged 79 commits intomainfrom Jan 10, 2026
Merged
Conversation
…rter Implements the full execution loop in the new session architecture, enabling actual task execution with intelligent caching and formatted output. Core changes: - Implement execute_spawn() with fspy tracking for file system access monitoring - Create PostRunFingerprint for content-based cache invalidation - Wire up LabeledReporter for formatted execution output with cache status - Migrate cache to use SpawnFingerprint from vite_task_plan - Add workspace_path() getter and make session module public Test infrastructure: - Add vite-task-smoke e2e test with replace-file-content utility - Add duration redaction to snapshot tests - Verify cache hit/miss detection with file modifications The execution now properly tracks file reads, validates fingerprints, and displays execution progress with cache status indicators. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace ExecuteError enum with event-based error reporting through the Reporter trait. Errors are now emitted as events and stop execution immediately via internal ExecutionAborted error. Key changes: - Add Reporter trait with handle_event() and post_execution() methods - Remove ExecuteError and PathError enums - Make ExecutionItemDisplay optional in Start event (None for top-level, Some for nested) - Convert all error returns to error events - Add internal ExecutionAborted type for error propagation via ? operator - Update Session::execute to accept Box<dyn Reporter> instead of closure - Implement Reporter trait for LabeledReporter with error tracking - Fix top-level leaf execution for built-in commands - Add cycle dependency error test fixture All tests pass with updated snapshots. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add oxc-project/setup-node before pnpm install for ubuntu/windows - Move actions/setup-node before pnpm install for x86_64-apple-darwin to ensure correct native binaries are installed - Redact thread count in oxlint output for consistent snapshots across machines with different CPU counts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Strip .CMD, .BAT, .EXE, .COM extensions from program_name in JSON snapshots for cross-platform consistency. On Windows, resolved program paths include these extensions but Unix doesn't use them. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The program_path field in spawn_command also includes the Windows executable extension (.CMD) which needs to be stripped for cross- platform snapshot consistency. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Handle both backslash and forward slash variants of paths for workspace_root and manifest_dir redaction - Normalize PATH separator from ; (Windows) to : (Unix) for cross-platform consistency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cmd.exe doesn't handle quoted arguments with embedded equals signs and brackets correctly. PowerShell has much better argument parsing that matches Unix shell behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cmd.exe needs system environment variables to function correctly. Instead of clearing all env vars on Windows, only clear them on Unix. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace platform-specific shell (cmd.exe/sh) with @yarnpkg/shell for consistent cross-platform behavior in e2e tests - Add Node.js experimental warning filtering in redact.rs to handle Type Stripping warnings from newer Node.js versions - Add @yarnpkg/shell 4.1.3 dependency to test_bins - Use `which` crate to locate shell executable in test_bins Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When oxlint scans a directory, it uses FindFirstFile/FindNextFile Win32 APIs to enumerate files. Without intercepting these calls, fspy wouldn't see READ_DIR accesses, causing the cache to miss file additions. This fix: - Adds detours for FindFirstFileW and FindFirstFileExW - Uses GetCurrentDirectoryW for relative patterns like "*" - Fixes fingerprint.rs to handle paths with trailing backslash Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
NtQueryDirectoryFile is already being intercepted at NT level, which correctly captures READ_DIR accesses when programs enumerate directories. The FindFirstFile Win32 API interception was unnecessary as it's just a wrapper around the NT API. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
On Windows CI, terminal color detection may behave differently, causing ANSI escape codes to appear in snapshot output even with NO_COLOR=1 set. Explicitly setting FORCE_COLOR=0 ensures colors are fully disabled. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The auto-add FORCE_COLOR logic was causing issues on Windows CI where stdout might be detected as supporting colors even when it's not a TTY. This caused oxlint to output ANSI color codes in its output. Changes: - Add IsTerminal check before auto-adding FORCE_COLOR - Also check FORCE_COLOR=0 in reporter color detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This reverts commit 2ccb1eb.
…n Windows" This reverts commit 631f2e0.
- Return 0 if all tasks succeed - Return the task's exit code if exactly one task failed - Return 1 if more than one task failed Update vite_task_bin to propagate the exit code to the process. Add e2e tests to verify exit code behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… ExitCode> Use Result type for clearer success/failure semantics: - Ok(()) for success (exit code 0) - Err(ExitCode) for failure with specific exit code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
8e6c165 to
0b3eed1
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements a major refactoring of the task execution system with a new Session-based architecture, improved caching with detailed miss reasons, and comprehensive cross-platform support.
Changes:
- Migrates to new Session API with event-based Reporter trait for execution feedback
- Implements detailed cache miss tracking (env changes, input changes, cwd changes) and cache metadata system
- Adds cross-platform support with Windows path handling, @yarnpkg/shell for tests, and proper environment variable preservation
Reviewed changes
Copilot reviewed 151 out of 211 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Adds test_bins workspace and new dependencies (oxlint, @yarnpkg/shell) |
| pnpm-lock.yaml | Updates lockfile with new test dependencies |
| package.json | Adds new dev dependencies and test scripts |
| crates/vite_task_plan/src/plan_request.rs | Adds envs field to SyntheticPlanRequest for environment customization |
| crates/vite_task_plan/src/plan.rs | Implements cd command handling, which() function, and cache key generation |
| crates/vite_task_plan/src/path_env.rs | Adds case-insensitive PATH lookup for Windows |
| crates/vite_task_plan/src/lib.rs | Refactors to use SpawnCommand and CacheMetadata structures |
| crates/vite_task_plan/src/cache_metadata.rs | New file defining cache metadata structures |
| crates/vite_task_graph/src/lib.rs | Refactors TaskId to be private, adds TaskDisplay to TaskNode |
| crates/vite_task_graph/src/display.rs | Updates TaskDisplay formatting |
| crates/vite_task_graph/src/config/*.rs | Restructures cache configuration with EnabledCacheConfig |
| crates/vite_task_bin/tests/* | Adds comprehensive snapshot testing infrastructure |
| crates/vite_task_bin/test_bins/* | Adds test utility programs (print-file, json-edit, etc.) |
| crates/vite_task_bin/src/* | New binary implementation with Session API usage |
| crates/vite_task/src/session/* | New session module with Reporter, cache, and execution logic |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fengmk2
approved these changes
Jan 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Major refactoring of the task execution system with a new Session-based architecture, improved caching with detailed miss reasons, and comprehensive cross-platform support.
Architecture Changes
vite_taskvite_task_bincrate for CLI and test infrastructureLabeledReporterfor formatted outputCache System Improvements
Execution Infrastructure
execute_spawn()with fspy tracking for file system access monitoringtokio::select!PostRunFingerprintfor content-based cache invalidationadditional_envsfieldCross-Platform Fixes
@yarnpkg/shellfor cross-platform e2e testsFindFirstFile/FindNextFileon Windows for cache invalidationTesting
test_binsutilities for testing (json-edit, print-env, print-file, replace-file-content)Other Changes
node_modules/.binto session PATH🤖 Generated with Claude Code